﻿<?php
    include("asn-config.php");
    require_once('./class.rc4crypt.php');

    // Create new user table
    $createUser = mysql_query('CREATE TABLE users (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255), password VARCHAR(255) )');

    if ($createUser)
    {
        $pwd = PWD;
        $data = "admin";

        $e = rc4crypt::encrypt($pwd, $data);
        $e = bin2hex($e);

        $query = "INSERT INTO users  VALUES ('' , 'admin', '$e')";
        $result = mysql_query($query);

        if( $result )
        {
            // Create new sdata table
            $createSData = mysql_query('CREATE TABLE posts (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, author VARCHAR(255), email VARCHAR(255), url VARCHAR(255), date VARCHAR(255), message VARCHAR(255) )');

            if ( $createSData )
            {
                mysql_close(); // Close the connection to the MySQL Server
                echo "Installation complete! For security reasons delete intall.php file";
            }
            else
            {
                echo "Error creating posts table! Try again";
            }
        }
        else
        {
            echo "Error inserting default user! Try again";
        }
    }
    else
    {
        echo "Error creating users table! Try again";
    }
?>